<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-2"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-3"></span><span class="hs-comment">-- Module      :  GHC.Lexeme</span><span>
</span><span id="line-4"></span><span class="hs-comment">-- Copyright   :  (c) The GHC Team</span><span>
</span><span id="line-5"></span><span class="hs-comment">--</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Maintainer  :  ghc-devs@haskell.org</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-8"></span><span class="hs-comment">--</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Functions to evaluate whether or not a string is a valid identifier.</span><span>
</span><span id="line-10"></span><span class="hs-comment">--</span><span>
</span><span id="line-11"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Lexeme</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-12"></span><span>          </span><span class="annot"><span class="hs-comment">-- * Lexical characteristics of Haskell names</span></span><span>
</span><span id="line-13"></span><span>        </span><span class="annot"><a href="GHC.Lexeme.html#startsVarSym"><span class="hs-identifier">startsVarSym</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Lexeme.html#startsVarId"><span class="hs-identifier">startsVarId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Lexeme.html#startsConSym"><span class="hs-identifier">startsConSym</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Lexeme.html#startsConId"><span class="hs-identifier">startsConId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.Lexeme.html#startsVarSymASCII"><span class="hs-identifier">startsVarSymASCII</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Lexeme.html#isVarSymChar"><span class="hs-identifier">isVarSymChar</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Lexeme.html#okSymChar"><span class="hs-identifier">okSymChar</span></a></span><span>
</span><span id="line-15"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-16"></span><span>
</span><span id="line-17"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-comment">-- See note [Why do we import Prelude here?]</span><span>
</span><span id="line-18"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Char.html#"><span class="hs-identifier">Data.Char</span></a></span><span>
</span><span id="line-19"></span><span>
</span><span id="line-20"></span><span class="hs-comment">-- | Is this character acceptable in a symbol (after the first char)?</span><span>
</span><span id="line-21"></span><span class="hs-comment">-- See alexGetByte in GHC.Parser.Lexer</span><span>
</span><span id="line-22"></span><span class="annot"><a href="GHC.Lexeme.html#okSymChar"><span class="hs-identifier hs-type">okSymChar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-23"></span><span id="okSymChar"><span class="annot"><span class="annottext">okSymChar :: Char -&gt; Bool
</span><a href="GHC.Lexeme.html#okSymChar"><span class="hs-identifier hs-var hs-var">okSymChar</span></a></span></span><span> </span><span id="local-6989586621679046228"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046228"><span class="hs-identifier hs-var">c</span></a></span></span><span>
</span><span id="line-24"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046228"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; [Char] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;(),;[]`{}_\&quot;'&quot;</span></span><span>
</span><span id="line-25"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-26"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-27"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Char -&gt; GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#generalCategory"><span class="hs-identifier hs-var">generalCategory</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046228"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-28"></span><span>      </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#ConnectorPunctuation"><span class="hs-identifier hs-var">ConnectorPunctuation</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-29"></span><span>      </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#DashPunctuation"><span class="hs-identifier hs-var">DashPunctuation</span></a></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-30"></span><span>      </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#OtherPunctuation"><span class="hs-identifier hs-var">OtherPunctuation</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-31"></span><span>      </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#MathSymbol"><span class="hs-identifier hs-var">MathSymbol</span></a></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-32"></span><span>      </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#CurrencySymbol"><span class="hs-identifier hs-var">CurrencySymbol</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-33"></span><span>      </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#ModifierSymbol"><span class="hs-identifier hs-var">ModifierSymbol</span></a></span><span>       </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-34"></span><span>      </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#OtherSymbol"><span class="hs-identifier hs-var">OtherSymbol</span></a></span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-35"></span><span>      </span><span class="annot"><span class="annottext">GeneralCategory
</span><span class="hs-identifier">_</span></span><span>                    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-36"></span><span>
</span><span id="line-37"></span><span class="annot"><a href="GHC.Lexeme.html#startsVarSym"><span class="hs-identifier hs-type">startsVarSym</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Lexeme.html#startsVarId"><span class="hs-identifier hs-type">startsVarId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Lexeme.html#startsConSym"><span class="hs-identifier hs-type">startsConSym</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Lexeme.html#startsConId"><span class="hs-identifier hs-type">startsConId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-38"></span><span id="startsVarSym"><span class="annot"><span class="annottext">startsVarSym :: Char -&gt; Bool
</span><a href="GHC.Lexeme.html#startsVarSym"><span class="hs-identifier hs-var hs-var">startsVarSym</span></a></span></span><span> </span><span id="local-6989586621679046218"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046218"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="GHC.Lexeme.html#okSymChar"><span class="hs-identifier hs-var">okSymChar</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046218"><span class="hs-identifier hs-var">c</span></a></span><span>&#160;</span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046218"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">':'</span></span><span> </span><span class="hs-comment">-- Infix Ids</span><span>
</span><span id="line-39"></span><span id="startsConSym"><span class="annot"><span class="annottext">startsConSym :: Char -&gt; Bool
</span><a href="GHC.Lexeme.html#startsConSym"><span class="hs-identifier hs-var hs-var">startsConSym</span></a></span></span><span> </span><span id="local-6989586621679046215"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046215"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046215"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">':'</span></span><span>                </span><span class="hs-comment">-- Infix data constructors</span><span>
</span><span id="line-40"></span><span id="startsVarId"><span class="annot"><span class="annottext">startsVarId :: Char -&gt; Bool
</span><a href="GHC.Lexeme.html#startsVarId"><span class="hs-identifier hs-var hs-var">startsVarId</span></a></span></span><span> </span><span id="local-6989586621679046214"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046214"><span class="hs-identifier hs-var">c</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046214"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'_'</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Char -&gt; GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#generalCategory"><span class="hs-identifier hs-var">generalCategory</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046214"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="hs-keyword">of</span><span>  </span><span class="hs-comment">-- Ordinary Ids</span><span>
</span><span id="line-41"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#LowercaseLetter"><span class="hs-identifier hs-var">LowercaseLetter</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-42"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><a href="../../base/src/GHC.Unicode.html#OtherLetter"><span class="hs-identifier hs-var">OtherLetter</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>   </span><span class="hs-comment">-- See #1103</span><span>
</span><span id="line-43"></span><span>  </span><span class="annot"><span class="annottext">GeneralCategory
</span><span class="hs-identifier">_</span></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-44"></span><span id="startsConId"><span class="annot"><span class="annottext">startsConId :: Char -&gt; Bool
</span><a href="GHC.Lexeme.html#startsConId"><span class="hs-identifier hs-var hs-var">startsConId</span></a></span></span><span> </span><span id="local-6989586621679046210"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046210"><span class="hs-identifier hs-var">c</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="../../base/src/GHC.Unicode.html#isUpper"><span class="hs-identifier hs-var">isUpper</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046210"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046210"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'('</span></span><span>  </span><span class="hs-comment">-- Ordinary type constructors and data constructors</span><span>
</span><span id="line-45"></span><span>
</span><span id="line-46"></span><span class="annot"><a href="GHC.Lexeme.html#startsVarSymASCII"><span class="hs-identifier hs-type">startsVarSymASCII</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-47"></span><span id="startsVarSymASCII"><span class="annot"><span class="annottext">startsVarSymASCII :: Char -&gt; Bool
</span><a href="GHC.Lexeme.html#startsVarSymASCII"><span class="hs-identifier hs-var hs-var">startsVarSymASCII</span></a></span></span><span> </span><span id="local-6989586621679046208"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046208"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046208"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; [Char] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="annot"><span class="annottext">[Char]
</span><span class="hs-string">&quot;!#$%&amp;*+./&lt;=&gt;?@\\^|~-&quot;</span></span><span>
</span><span id="line-48"></span><span>
</span><span id="line-49"></span><span class="annot"><a href="GHC.Lexeme.html#isVarSymChar"><span class="hs-identifier hs-type">isVarSymChar</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Char</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-50"></span><span id="isVarSymChar"><span class="annot"><span class="annottext">isVarSymChar :: Char -&gt; Bool
</span><a href="GHC.Lexeme.html#isVarSymChar"><span class="hs-identifier hs-var hs-var">isVarSymChar</span></a></span></span><span> </span><span id="local-6989586621679046207"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046207"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046207"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">':'</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Bool
</span><a href="GHC.Lexeme.html#startsVarSym"><span class="hs-identifier hs-var">startsVarSym</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679046207"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-51"></span></pre></body></html>